package com.changgou.goods.service.impl;

import com.changgou.goods.dao.SkuMapper;
import com.changgou.goods.pojo.Sku;
import com.changgou.goods.service.SkuService;
import entity.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.util.StringUtil;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class SkuServiceImpl implements SkuService {

    @Autowired
    private SkuMapper skuMapper;

    @Override
    public Map search(Map<String, String> searchMap) {
        String keywords = searchMap.get("keywords");
        if (StringUtil.isEmpty(keywords)){
            keywords="TCL";
        }
        //搜索对象
        List<Sku> skuList = skuMapper.searchByName("%"+keywords+"%");

        //返回result
        Map resultMap = new HashMap<>();
        resultMap.put("rows",skuList);
        return resultMap;
    }

    @Override
    public List<Sku> findList(Sku sku) {
        return skuMapper.select(sku);
    }


}
